<?php
Yii::import('web.models.AccountTokenSinglePeriodStat');

class AccountTokenSinglePeriodPrint extends AccountTokenSinglePeriodStat {
	public $number;
	public $tokenDate;
	public $tokenNumberMin;
	public $tokenNumberMax;

	public $items = array();
	public $createUser;
	public $totalDebit;
	public $totalCredit;

	public function rules() {
		return CMap::mergeArray(parent::rules(),
			array(
				array(
					'number, tokenDate, tokenNumberMax, tokenNumberMin',
					'required'
				),
				array(
					'number, tokenNumberMax, tokenNumberMin',
					'numerical',
					'integerOnly' => true,
				),
			));
	}

	public function attributeLabels() {
		return CMap::mergeArray(parent::attributeLabels(),
			array(
				'number' => '编号',
				'tokenDate' => '凭证日期',
				'tokenNumberMin'=>'凭证号',
				'tokenNumberMax'=>'凭证号',
			));
	}
	public function getProjectName() {
		if ($this->projectId) {
			return AccountTokenProject::model()->findByPk($this->projectId)->name;
		}
		return '全部公司账目';
	}
	public function isBalanced() {
		return $this->totalCredit == $this->totalDebit;
	}
}

class AccountTokenSinglePeriodPrintItem {
	public $category;
	public $credit;
	public $debit;
}
